package com.sctvcloud.dongqu.http;

import java.io.Serializable;

/**
 * Created by panxd on 2016/9/5.
 */
public class NetResponseBase implements Serializable {
    private static final long serialVersionUID = 2614250482510630587L;
    protected int rs;
    protected String error;

    protected int size;
    protected int page;
    protected int total;
    protected int count;
//    protected int ShowType;
    protected String code;
    protected int index;

    private IWhenSucDoOther whenSucDoOther;

    public interface IWhenSucDoOther {
        <T extends NetResponseBase> void whenSucDoOther(T t);
    }

    public int getRs() {
        return rs;
    }

    public void setRs(int rs) {
        this.rs = rs;
    }

    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }

    public boolean isNetOk() {
//        return "ok".equals(rs) || "200".equals(rs);
        return rs == 200;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getTotal() {
        return total;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }
    //    public int getShowType() {
//        return ShowType;
//    }
//
//    public void setShowType(int showType) {
//        this.ShowType = showType;
//    }

    public NetResponseBase setWhenSucDoOther(IWhenSucDoOther whenSucDoOther) {
        this.whenSucDoOther = whenSucDoOther;
        return this;
    }

    public <T extends NetResponseBase> void whenSucdoOthers(T t) {
        if (whenSucDoOther != null) {
            whenSucDoOther.whenSucDoOther(t);
        }
    }

    @Override
    public String toString() {
        return
                "rs='" + rs + '\'' +
                        ", error='" + error + '\'' +
                        ", count='" + count + '\'' +
                        ", page=" + page +
                        ", total=" + total;
    }
}
